﻿<tr class="@RowClassString" @onclick="@ClickRow">
    <td>Cell1</td>
    <td>Cell2</td>
    <td>Cell3</td>
</tr>

@code {
    private string RowClassString => Active ? "active" : null;

    private bool Active;

    private void ClickRow()
    {
        Dispatch?.Reset();
        Active = true;
    }

    protected override async Task OnInitializedAsync()
    {
        await base.OnInitializedAsync();

        if (Dispatch != null)
        {
            Dispatch.ResetActive += () =>
            {
                if (Active)
                {
                    Active = false;
                    StateHasChanged();
                }
            };
        }
    }

    [CascadingParameter]
    private RowClickEvent Dispatch { get; set; }
}
